var graph = argument0;
var nodesPruned = 0;
var height = array_height_2d(graph) ;
var width = array_length_2d(graph, 0);
do
{
    nodesPruned = 0;
    for (var iii = 0; iii < height; iii++)
    {
        for (var jjj = 0; jjj < width; jjj++)
        {
            if (graph[iii, jjj] != 1)
            {
                continue;
            }

            var exposures = 0;
            if (jjj + 1 < width && graph[iii, jjj + 1] != 0)
            {
                exposures++;
            }
            if (iii - 1 > -1 && graph[iii - 1, jjj] != 0)
            {
                exposures++;
            }
            if (jjj - 1 > -1 && graph[iii, jjj - 1] != 0)
            {
                exposures++;
            }
            if (iii + 1 < height && graph[iii + 1, jjj] != 0)
            {
                exposures++;
            }
            if (exposures == 1)
            {
                graph[iii, jjj] = 0;
                nodesPruned++;
            }
        }
    }
} until (nodesPruned == 0);
return graph;
